package com.flx.at.spring.code.test.testconditional.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @Author: Fenglixiong
 * @Date: 2021/7/3 16:40
 * @Description: 条件判断，当父类存在的时候才会加载母亲类
 */
public class RelationCondition implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        if(conditionContext.getBeanFactory().containsBean("father")){
            return true;
        }
        return false;
    }

}
